﻿using SH;
using System;
using System.Collections.Generic;
using System.Text;

namespace MTS
{
    class mtSMSServer : mtInterface, ImtSMSServer
    {
       public mtSMSServer()
            : base("mtSMSServer")
        {

        }

        protected override shErrorCode _Initialize()
        {
            BindEpic(emProgramType.emPT_CSS, ImtCSSServerCallback._classID);

            return shErrorCode.sh_ec_Success;
        }

        shErrorCode ImtSMSServer.GetStorageCapacity( out mtStorageCapacityInfo info)
        {
            MTSSerializer sc = new MTSSerializer();

            var ec = __InvokeTwoWay(ImtCSSServerCallback._classID, ImtCSSServerCallback.CSSServerStorageCapacity, ref sc);

            if(ec != shErrorCode.sh_ec_Success)
            {
                info = null;

                return ec;
            }

            info = new mtStorageCapacityInfo();
            sc.serialize(info);

            return ec;
        }


        shErrorCode ImtSMSServer.DeleteImage( mtDeleteImageDemand req, out mtDeleteImageReply rsp)
        {

            MTSSerializer sc = new MTSSerializer();

            sc.serialize(req);

            var ec = __InvokeTwoWay(ImtCSSServerCallback._classID, ImtCSSServerCallback.CSSServerDeleteImage, ref sc);

            if (ec != shErrorCode.sh_ec_Success)
            {
                rsp = null;

                return ec;
            }

            rsp = new mtDeleteImageReply();

            sc.serialize(rsp);

            return ec;
        }

         shErrorCode ImtSMSServer.SaveImage( mtSaveImageRequest req, out mtSaveImageResponse rsp)
        {
            MTSSerializer sc = new MTSSerializer();

            sc.serialize(req);

            var ec = __InvokeTwoWay(ImtCSSServerCallback._classID, ImtCSSServerCallback.CSSServerSaveImage,  ref sc);

            if (ec != shErrorCode.sh_ec_Success)
            {
                rsp = null;

                return ec;
            }

            rsp = new mtSaveImageResponse();

            sc.serialize(rsp);

            return ec;
        }

       


        shErrorCode ImtSMSServer.SetRecognizeAlgorithm( mtRecognizeAlgorithm info)
        {
            MTSSerializer sc = new MTSSerializer();

            sc.serialize(info);

            var ec = __InvokeOneWay(ImtRCGCallback._classID, ImtRCGCallback.RCGSetRecognizeAlgorithm, sc);

            return ec;
        }


         shErrorCode ImtSMSServer.UpdateCredential(mtCredential crd)
        {

            MTSSerializer sc = new MTSSerializer();

            sc.serialize(crd);

            var ec = __InvokeTwoWay(ImtSysManageCallback._classID, ImtSysManageCallback.SysManageUpdateCredential, crd.Token,ref sc);
      

          return ec;

        }
    }
}
